<template>
  <div class="mod-config">
    <el-form  :model="dataForm" label-width="100px">
      <el-card style="width: 100%;" shadow="hover">
        <div slot="header" class="clearfix">
          <span>查询条件</span>
        </div>
        <div>
          <el-row>
            <el-col :span="8">
              <el-form-item label="个人编码" prop="personalCode">
                  <el-input v-model="dataForm.personalCode" placeholder="个人编码"  :style="{ width: '60%' }" clearable></el-input>
              </el-form-item>    
            </el-col>
            <el-col :span="8">
              <el-form-item label="姓名" prop="name">
                  <el-input v-model="dataForm.name" placeholder="姓名"  :style="{ width: '60%' }" clearable></el-input>
              </el-form-item>    
            </el-col>
            <el-col :span="8">
              <el-form-item label="身份证号" prop="idNo">
                  <el-input v-model="dataForm.idNo" placeholder="身份证号"  :style="{ width: '60%' }" clearable></el-input>
              </el-form-item>     
            </el-col>
          </el-row>
        </div>
      </el-card>    
      <el-row style="margin-bottom:12px;margin-top:12px">
        <el-col :span="12">  
            <el-button @click="getSearchDataList()">查询</el-button>
            <!-- <el-button  type="primary" @click="exportData()">导出</el-button> -->
           
        </el-col>
      </el-row>
    </el-form>
    <el-table
      :data="dataList"
      border
      v-loading="dataListLoading"
      @selection-change="selectionChangeHandle"
      style="width: 100%;">
      <el-table-column
        type="selection"
        header-align="center"
        align="center"
        width="50">
      </el-table-column>
      <el-table-column
        fixed
        prop="areaCode"
        header-align="center"
        align="center"
        label="行政区划代码"
        width="120">
      </el-table-column>
      <el-table-column
        fixed
        prop="personalCode"
        header-align="center"
        align="center"
        label="个人编码"
        width="140">
      </el-table-column>
      <el-table-column
        fixed
        prop="name"
        header-align="center"
        align="center"
        label="姓名">
      </el-table-column>
       <el-table-column
        prop="sex"
        header-align="center"
        align="center"
        label="性别">
      </el-table-column>
      <el-table-column
        prop="nation"
        header-align="center"
        align="center"
        label="民族">
      </el-table-column>
      <el-table-column
        prop="politicalFace"
        header-align="center"
        align="center"
        label="政治面目"
        width="120">
      </el-table-column>
      <el-table-column
        prop="idNo"
        header-align="center"
        align="center"
        label="身份证号码"
        width="180">
      </el-table-column>
      <el-table-column
        prop="birthDate"
        header-align="center"
        align="center"
        label="出生年月"
        format="yyyy 年 MM 月 dd 日"
        width="120">
      </el-table-column>
      <el-table-column
        prop="workTime"
        header-align="center"
        align="center"
        label="参加工作时间"
        width="120">
      </el-table-column>
      <el-table-column
        prop="retirementTime"
        header-align="center"
        align="center"
        label="退休时间"
        width="120">
      </el-table-column>
      <el-table-column
        prop="personType"
        header-align="center"
        align="center"
        label="人员分类"
        width="120">
      </el-table-column>
      <el-table-column
        prop="retirementStatus"
        header-align="center"
        align="center"
        label="退休前身份"
        width="180">
      </el-table-column>
      <el-table-column
        prop="duties"
        header-align="center"
        align="center"
        label="职务"
        width="140">
      </el-table-column>
      <el-table-column
        prop="county"
        header-align="center"
        align="center"
        label="所属区县"
        width="140">
      </el-table-column>
      <el-table-column
        prop="street"
        header-align="center"
        align="center"
        label="所属街道"
        width="140">
      </el-table-column>
      <el-table-column
        prop="community"
        header-align="center"
        align="center"
        label="居住社区"
        width="140">
      </el-table-column>
      <el-table-column
        prop="originalTroops"
        header-align="center"
        align="center"
        label="原部队"
        width="140">
      </el-table-column>
      <el-table-column
        prop="handoverPeriod"
        header-align="center"
        align="center"
        label="移交时间段"
        width="140">
      </el-table-column>
      <el-table-column
        prop="handoverTime"
        header-align="center"
        align="center"
        label="移交时间"
        width="140">
      </el-table-column>
      <el-table-column
        prop="handoverMode"
        header-align="center"
        align="center"
        label="移交方式"
        width="140">
      </el-table-column>
      <el-table-column
        prop="handoverBatch"
        header-align="center"
        align="center"
        label="移交批次"
        width="140">
      </el-table-column>
      <el-table-column
        prop="workersClassification"
        header-align="center"
        align="center"
        label="职工分类"
        width="140">
      </el-table-column>
      <el-table-column
        prop="reception"
        header-align="center"
        align="center"
        label="接收情况"
        width="140">
      </el-table-column>
      <el-table-column
        prop="myStatus"
        header-align="center"
        align="center"
        label="本人状态"
        width="140">
      </el-table-column>
      <el-table-column
        prop="inOutTime"
        header-align="center"
        align="center"
        label="转入转出时间"
        width="140">
      </el-table-column>
      <el-table-column
        fixed="right"
        header-align="center"
        align="center"
        width="150"
        label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="recoveryData(scope.row.id)">恢复数据</el-button>
        </template>
      </el-table-column>
      
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
  </div>
</template>
<script>
  export default {
    data () {
      return {
        show3: false,
        countyList: [],
        streetList: [],
        dataForm: {
          key: '',
          street: '',
          county: '',
          deathTime1: '',
          deathTime2: '',
          logoutDate1: '',
          logoutDate2: '',
          personalCode: '',
          name:'',
          idNo:''
        },
        exportList:[],
        dataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        dataListSelections: [],
        addOrUpdateVisible: false,
      }
    },
    activated () {
      this.getDataList()
      //this.getName()
    },
    created(){
     // this.dataSex('AREA')
    },

    methods: {
      // 获取数据列表
      getDataList () {
        // alert(this.dataForm.name);
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/jxxm/honorableemployees/listDelete'),
          method: 'get',
          params: this.$http.adornParams({
            'page': this.pageIndex,
            'limit': this.pageSize,
            'personalCode':this.dataForm.personalCode,
            'name':this.dataForm.name,
            'idNo':this.dataForm.idNo

          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataList = data.page.list
            this.totalPage = data.page.totalCount
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      // 获取查询数据列表
      getSearchDataList () {
        // alert(this.dataForm.name);
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/jxxm/honorableemployees/searchListDelete'),
          method: 'get',
          params: this.$http.adornParams({
            'page': 1,
            'limit': 10,
            'personalCode':this.dataForm.personalCode,
            'name':this.dataForm.name,
            'idNo':this.dataForm.idNo

          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataList = data.page.list
            this.totalPage = data.page.totalCount
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },
      // 多选
      selectionChangeHandle (val) {
        this.dataListSelections = val
      },
      dataSex(type){
         this.$http({
            url: this.$http.adornUrl("/sys/dict/select/"+type),
            method: "get",
            params: this.$http.adornParams(),
            })
            .then(({ data }) => {      
                this.countyList = data && data.code === 0 ? data.list : [];  
            })
      },
      //地区联动专用
      dataArea(val,type){
     
         this.$http({
            url: this.$http.adornUrl("/sys/dict/select/"+type),
            method: "get",
            params: this.$http.adornParams(),
            })
            .then(({ data }) => {
                if (type == "AREA") {
                  this.countyList = data && data.code === 0 ? data.list : [];
                }
                this.$http({
                  url: this.$http.adornUrl("/sys/dict/secondary/"+val),
                  method: "get",
                  params: this.$http.adornParams(),
                  }).then(({ data }) => {                 
                      if (type == "AREA") {
                      this.dataForm.street = null;
                      this.streetList = data && data.code === 0 ? data.list : [];
                    }
                     
                  })
            })
      },
      // 恢复数据
      recoveryData (id) {
        var ids = id ? [id] : this.dataListSelections.map(item => {
          return item.id
         })
         this.$http({
            url: this.$http.adornUrl('/jxxm/honorableemployees/recoveryData'),
            method: 'post',
            data: this.$http.adornData(ids, false)
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                  this.getDataList()
                }
              })
            } else {
              this.$message.error(data.msg)
            }
          })
        
      },
    }
  }
</script>
